package com.chendx.store.comment.controller;

import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.goodsComment.dto.SkuCommentDto;
import com.chendx.model.goodsComment.vo.CommentCountVo;
import com.chendx.store.api.comment.CommentControllerApi;
import com.chendx.store.comment.service.GoodsCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chendx on 2022/4/21.
 */
@RestController
@RequestMapping("/api/comment")
public class CommentController implements CommentControllerApi {

    @Autowired
    private GoodsCommentService goodsCommentService;

    @Override
    @PostMapping
    public ResponseResult add(@RequestBody SkuCommentDto dto) {
        return goodsCommentService.add(dto);
    }

    @Override
    @PostMapping("/list")
    public ResponseResult list(@RequestBody SkuCommentDto dto) {
        return goodsCommentService.list(dto);
    }

    @Override
    @GetMapping("/onebysku")
    public ResponseResult findBySkuid(String skuId) {
        return goodsCommentService.findBySkuid(skuId);
    }

    @Override
    @GetMapping("/onebyspu")
    public ResponseResult findBySpuid(String spuId) {
        return goodsCommentService.findBySpuid(spuId);
    }

    @Override
    @GetMapping("/onebyp")
    public ResponseResult findByParentid(String parentId) {
        return goodsCommentService.findByParentid(parentId);
    }

    @Override
    @GetMapping("/count")
    public ResponseResult findCountBySkuid(String skuid) {
        return goodsCommentService.findCountBySkuid(skuid);
    }



    @Override
    @GetMapping("/loadDetail")
    public CommentCountVo loadCommentDetail(String skuid) {
        return goodsCommentService.loadCommentDetail(skuid);
    }


}
